/*     */ package com.qmsk.business.store.goodsTypeLrg.controller;
/*     */ 
/*     */ import com.qmsk.business.store.goodsTypeLrg.dao.GoodsTypeLrgDao;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.io.IOException;
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/goodsTypeLrg"})
/*     */ public class GoodsTypeLrgController
/*     */ {
/*  35 */   private static final Logger logger = Logger.getLogger(GoodsTypeLrgController.class);
/*     */ 
/*     */   @Autowired
/*     */   private GoodsTypeLrgDao dao;
/*     */ 
/*     */   @RequestMapping(value={"find/opt/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOptShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  54 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  56 */       Map params = new HashMap();
/*  57 */       MapUtils.addToMap(params, "id", RequestUtils.getLong(request, "id"));
/*     */ 
/*  59 */       MapUtils.addPercentToMap(params, "name", 
/*  60 */         RequestUtils.getString(request, "name"));
/*  61 */       MapUtils.addPercentToMap(params, "code", 
/*  62 */         RequestUtils.getString(request, "code"));
/*     */ 
/*  64 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/*  65 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     }
/*     */     catch (Exception e) {
/*  68 */       logger.error(e);
/*     */ 
/*  70 */       ResponseUtils.setErrorMsgResponse(
/*  71 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/all"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOptShopId(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try {
/*  79 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll();
/*  80 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     }
/*     */     catch (Exception e) {
/*  83 */       logger.error(e);
/*     */ 
/*  85 */       ResponseUtils.setErrorMsgResponse(
/*  86 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/id/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfId(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") Long id)
/*     */   {
/*     */     try {
/*  94 */       Map params = new HashMap();
/*  95 */       MapUtils.addToMap(params, "id", id);
/*     */ 
/*  97 */       GsonEbRst gsonEbRst = this.dao.getGsonOfId(params);
/*  98 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 100 */       logger.error(e);
/* 101 */       ResponseUtils.setErrorMsgResponse(
/* 102 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */     throws IOException
/*     */   {
/*     */     try
/*     */     {
/* 122 */       int nResult = 0;
/* 123 */       String sData = RequestUtils.getStringOfData(request);
/* 124 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/*     */ 
/* 126 */       nResult = this.dao.applyUpdates(p);
/*     */ 
/* 128 */       if (nResult > 0)
/* 129 */         DbConnection.commit();
/*     */       else {
/* 131 */         DbConnection.rollback();
/*     */       }
/*     */ 
/* 134 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 135 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 136 */         response);
/*     */     } catch (Exception e) {
/* 138 */       DbConnection.rollback();
/* 139 */       logger.error(e);
/* 140 */       ResponseUtils.setErrorMsgResponse(
/* 141 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 142 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 156 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 158 */       String[] strParams = id.split(",");
/*     */ 
/* 160 */       int nResult = this.dao.deleteParams(strParams);
/*     */ 
/* 162 */       if (nResult > 0)
/* 163 */         DbConnection.commit();
/*     */       else {
/* 165 */         DbConnection.rollback();
/*     */       }
/*     */ 
/* 168 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 169 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 170 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 173 */       DbConnection.rollback();
/* 174 */       logger.error(e);
/* 175 */       ResponseUtils.setErrorMsgResponse(
/* 176 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 177 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void update(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/* 195 */       int nResult = 0;
/* 196 */       String sData = RequestUtils.getStringOfData(request);
/* 197 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 198 */       if (p != null) {
/* 199 */         nResult = this.dao.applyUpdates(p);
/*     */       }
/* 201 */       if (nResult > 0)
/* 202 */         DbConnection.commit();
/*     */       else {
/* 204 */         DbConnection.rollback();
/*     */       }
/* 206 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 207 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 208 */         response);
/*     */     } catch (Exception e) {
/* 210 */       logger.error(e);
/* 211 */       DbConnection.rollback();
/* 212 */       ResponseUtils.setErrorMsgResponse(
/* 213 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 214 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.store.goodsTypeLrg.controller.GoodsTypeLrgController
 * JD-Core Version:    0.5.3
 */